0
1
00:00:00,330 --> 00:00:05,910
In this lesson we're going to learn about Data Visualization and Data Exploration.
1

2
00:00:06,090 --> 00:00:12,960
So, why visualize our data? Well, graphs and charts are incredibly powerful and very useful in being able
2

3
00:00:12,960 --> 00:00:18,240
to understand what it is that we're actually dealing with because there's actually only so much that
3

4
00:00:18,240 --> 00:00:20,990
you can learn from looking at a table of numbers.
4

5
00:00:21,000 --> 00:00:26,340
Very often you want to put it up on a chart so that way you can spot problems, you can spot outliers,
5

6
00:00:26,550 --> 00:00:29,490
you can spot trends and you can spot patterns.
6

7
00:00:29,520 --> 00:00:36,470
Pictures are incredibly informative, so let's create this chart in something called Jupyter notebook.
7

8
00:00:36,480 --> 00:00:39,840
Head on over to a website called jupyter.org.
8

9
00:00:39,840 --> 00:00:45,390
If you scroll down here then there's a button where it says "Try it in your browser", and this will take
9

10
00:00:45,390 --> 00:00:48,030
you to jupyter.org/try.
10

11
00:00:48,480 --> 00:00:54,220
I want to put a link to this very site in the course resources so you'll find it there as well.
11

12
00:00:54,240 --> 00:00:58,350
Once you're here click on "Try Jupiter with Python".
12

13
00:00:58,350 --> 00:01:03,550
And after a little loading time then you should be dropped off on a screen like this.
13

14
00:01:03,630 --> 00:01:08,520
Now if you didn't end up on the page that I showed you just now and instead you got this message then
14

15
00:01:08,670 --> 00:01:14,700
you can do one of two things: either you can skip ahead and see how we can install Jupyter or you can
15

16
00:01:14,700 --> 00:01:16,840
wait a few minutes and just refresh.
16

17
00:01:16,980 --> 00:01:19,510
And that should drop you off somewhere like this.
17

18
00:01:19,530 --> 00:01:22,020
So, why do I like Jupyter and why are we using it?
18

19
00:01:22,020 --> 00:01:23,860
Well this is an incredible tool.
19

20
00:01:23,880 --> 00:01:25,150
It's very powerful.
20

21
00:01:25,170 --> 00:01:28,430
It's very easy to use and it provides instant feedback.
21

22
00:01:28,470 --> 00:01:32,920
When we're writing our Python code Jupyter works on something called cells.
22

23
00:01:33,060 --> 00:01:36,680
And you can execute the code in these cells individually.
23

24
00:01:36,690 --> 00:01:37,650
Let me show you what I mean.
24

25
00:01:38,160 --> 00:01:44,580
So with this little plus sign here you can insert your cells and if you type something in one of these
25

26
00:01:44,580 --> 00:01:52,290
cells, say 5+5 and hit Shift+Enter on your keyboard, then this cell will execute and you'll
26

27
00:01:52,290 --> 00:01:54,260
see the output below the cell.
27

28
00:01:54,540 --> 00:01:59,670
Alternatively, if you don't wanna use the keyboard shortcut there's also this Run button up here.
28

29
00:01:59,670 --> 00:02:06,630
So let me just change this to 5+6 and press Run then you'll see this cell being executed and
29

30
00:02:06,630 --> 00:02:08,860
the output being updated.
30

31
00:02:08,880 --> 00:02:13,020
The other reason I really like Jupyter notebook is because it's fantastic at allowing you to present
31

32
00:02:13,020 --> 00:02:17,580
information because the cells are actually all not created equal.
32

33
00:02:17,610 --> 00:02:23,800
Some of these cells only present you with information like these ones and these are so-called markdown
33

34
00:02:23,910 --> 00:02:30,840
cells and other cells are actually cells that expect Python code like these ones and you can see this
34

35
00:02:30,950 --> 00:02:32,940
in the difference in the formatting.
35

36
00:02:32,940 --> 00:02:35,400
Now let me show you how to start a notebook of our own.
36

37
00:02:35,460 --> 00:02:40,860
If I click up here what says Jupyter just on the logo, I could take into something that looks a little
37

38
00:02:40,860 --> 00:02:43,890
bit like a Windows Explorer or Mac finder.
38

39
00:02:43,890 --> 00:02:46,010
I've got folders and files on him.
39

40
00:02:46,260 --> 00:02:55,470
And here I can click on New and say New Notebook and I can specify that I want a new Python 3 notebook
40

41
00:02:56,210 --> 00:03:02,890
and this will open a new tab in my browser with a fresh notebook that we can use for this project.
41

42
00:03:02,910 --> 00:03:09,240
So let's get this notebook a name instead of it being called Untitled let's call it Linear Regression
42

43
00:03:10,020 --> 00:03:11,740
and then we'll hit Rename.
43

44
00:03:12,030 --> 00:03:19,820
And if you change tabs back to the first tab here, you can see this notebook appear in green right here.
44

45
00:03:19,890 --> 00:03:24,900
So, how do we get our data from our spreadsheet into our Jupyter notebook?
45

46
00:03:24,900 --> 00:03:31,770
Well there's a small button here called Upload and if you click on it then you can upload a CSV file
46

47
00:03:32,010 --> 00:03:33,510
to Jupyter.
47

48
00:03:33,510 --> 00:03:39,870
Now you can either download your data from the Google Sheet in a CSV or a comma separated value format.
48

49
00:03:39,870 --> 00:03:46,470
But what I'd recommend is to download the cost_revenue_clean.csv file that
49

50
00:03:46,470 --> 00:03:49,040
we've provided in the course resources.
50

51
00:03:49,230 --> 00:03:52,870
This way we can ensure that we're all working from the same clean data.
51

52
00:03:52,980 --> 00:03:54,840
And there's no accidental typos.
52

53
00:03:54,990 --> 00:03:59,490
So just select this file and hit Open and then confirm your Upload.
53

54
00:03:59,490 --> 00:04:01,750
You should then see the CSV file appear right here.
54

55
00:04:02,220 --> 00:04:07,670
So now we've uploaded it successfully, heading back into our Jupyter notebook.
55

56
00:04:07,770 --> 00:04:12,790
We now have to get the data from the CSV file into our notebook.
56

57
00:04:12,810 --> 00:04:17,240
In other words, we need a way of accessing the data in the notebook itself.
57

58
00:04:17,250 --> 00:04:20,940
The problem is is that our notebook is currently blank.
58

59
00:04:20,940 --> 00:04:23,380
It doesn't know how to do anything yet.
59

60
00:04:23,460 --> 00:04:29,430
So we have to give our notebooks some sort of functionality and we can do this by accessing code that
60

61
00:04:29,520 --> 00:04:35,370
other people have already written and taking advantage of that other people's Python code is bundled
61

62
00:04:35,370 --> 00:04:37,470
up in something called a module.
62

63
00:04:37,740 --> 00:04:44,370
And in order to use a module in our notebook we have to import this module. The first module that I'd
63

64
00:04:44,370 --> 00:04:48,180
like to introduce to you is called pandas.
64

65
00:04:48,180 --> 00:04:55,500
So if you write import pandas in his very first cell and hit Shift+Enter on our keyboard or press this
65

66
00:04:55,500 --> 00:04:59,010
little Run button, then we've accomplished just that.
66

67
00:04:59,040 --> 00:05:06,690
Now our notebook has all the functionality that the pandas module has. Pandas is one of the key modules
67

68
00:05:06,780 --> 00:05:11,240
for Data Science and we'll be using it a lot on this course.
68

69
00:05:11,250 --> 00:05:17,670
It's incredibly useful from manipulating and analyzing data and the pandas module can already help us
69

70
00:05:17,700 --> 00:05:20,370
because it knows how to read CSV files.
70

71
00:05:20,370 --> 00:05:23,430
So let's use it to get the data into our Jupyter notebook.
71

72
00:05:23,550 --> 00:05:31,760
If we write pandas.read_csv and then we open a pair of parentheses,
72

73
00:05:31,950 --> 00:05:38,260
then we can supply the file name of our CSV file between these two single quotes. Our file name,
73

74
00:05:38,280 --> 00:05:46,700
if you recall was cost_revenue_clean.csv and you can see that right here.
74

75
00:05:47,370 --> 00:05:52,350
So I'm just going to copy this and then paste it in between these two single quotes.
75

76
00:05:52,410 --> 00:05:59,310
The key thing to understand here is that we're accessing the ability to read CSV files from the pandas
76

77
00:05:59,310 --> 00:06:06,090
module using this dot notation, but now that we've read our CSV file we need to store the data from this
77

78
00:06:06,090 --> 00:06:06,810
file somewhere.
78

79
00:06:07,290 --> 00:06:14,010
So we need some sort of object that holds onto our data like a container and we can create this simply
79

80
00:06:14,010 --> 00:06:21,930
by writing data = on the left hand side and then having pandas.read_csv on the right hand
80

81
00:06:21,930 --> 00:06:22,570
side.
81

82
00:06:22,590 --> 00:06:29,520
What this will do is it will create an object called data which then gets a value data that's contained
82

83
00:06:29,610 --> 00:06:31,400
inside the CSV file.
83

84
00:06:31,530 --> 00:06:34,120
And if we run the cell we can actually look at it.
84

85
00:06:34,140 --> 00:06:43,450
So let's click Run and then write data and then just hit Run again and here what we should see is all
85

86
00:06:43,450 --> 00:06:49,650
the data points and all the information that was previously stored inside our CSV file.
86

87
00:06:49,660 --> 00:06:56,920
The great thing about this is now we have an object in our notebook that we can use to analyze and explore
87

88
00:06:56,920 --> 00:06:57,490
our data.
88

89
00:06:57,730 --> 00:06:59,220
Let me show you what I mean.
89

90
00:06:59,260 --> 00:07:06,310
So instead of printing out all these 5000 rows below the cell what we can do is we can put a dot after
90

91
00:07:06,310 --> 00:07:11,160
our data object and tell it to describe itself.
91

92
00:07:11,320 --> 00:07:19,060
So with data.describe and two parentheses at the end, and hitting Shift+Enter we get the following
92

93
00:07:19,060 --> 00:07:26,980
output : we get some summary statistics on the data that's in the two columns - our production budgets and our
93

94
00:07:26,980 --> 00:07:33,910
worldwide gross, we get to see how many entries were in our data frame, we get to see how many entries
94

95
00:07:34,060 --> 00:07:35,790
were in these columns.
95

96
00:07:35,890 --> 00:07:40,850
In this case we have 5034 entries.
96

97
00:07:40,900 --> 00:07:46,330
The reason that these numbers look a little bit funny is because they're in scientific notation.
97

98
00:07:46,390 --> 00:07:56,560
So for example 5.034e3 equates to 5034 and 
98

99
00:07:56,560 --> 00:08:04,090
3.29e7 equates to 32 million so 3.29e7 or 3.29 million
99

100
00:08:04,150 --> 00:08:11,200
is actually the average production budget of all the films in our dataset and this is what
100

101
00:08:11,200 --> 00:08:18,130
we see here labeled as the mean. But not only do we get the number of entries and the average of the
101

102
00:08:18,130 --> 00:08:24,120
values but we can also see a number of other statistics like the minimum value the smallest value to
102

103
00:08:24,130 --> 00:08:31,990
the smallest production budget was and one hundred dollars and we also see the smallest amount of worldwide
103

104
00:08:32,020 --> 00:08:35,770
gross revenue which was 2600 dollars.
104

105
00:08:35,770 --> 00:08:38,620
So now we've got all our data in one place.
105

106
00:08:38,620 --> 00:08:46,510
We have it all stored inside an object called data but let's separate it out let's separate out what
106

107
00:08:46,510 --> 00:08:52,420
we're using to make our prediction our production budget from what we're going to predict, namely our
107

108
00:08:52,420 --> 00:08:53,830
gross revenue.
108

109
00:08:53,830 --> 00:08:58,420
And the reason we're doing this is because we're preparing our data for the next steps.
109

110
00:08:58,600 --> 00:09:03,220
We want to be able to create some charts and we want to be able to create our linear regression.
110

111
00:09:03,280 --> 00:09:08,410
So it's going to be very, very nice to stay organized and have our features separated from our target.
111

112
00:09:08,800 --> 00:09:14,290
So I come down here to a new cell and I'm going to create two more objects.
112

113
00:09:14,290 --> 00:09:19,300
One is going to be called capital X. And the other one is going to be called lowercase y.
113

114
00:09:19,690 --> 00:09:27,100
Now our X is going to hold on to our production budgets and our y is going to hold on to our revenue.
114

115
00:09:27,340 --> 00:09:31,330
So we're using that equals sign again just as we did up here.
115

116
00:09:31,360 --> 00:09:37,840
So now we have to think about what should these two things be equal to? What kind of object should our
116

117
00:09:37,900 --> 00:09:40,170
X and our y be at this point?
117

118
00:09:40,270 --> 00:09:44,750
I'd like to introduce you to one of the main workhorses of data science:
118

119
00:09:45,040 --> 00:09:51,280
the pandas data frame. You can think of a data frame as a very powerful spreadsheet, like a spreadsheet
119

120
00:09:51,280 --> 00:09:52,530
on steroids.
120

121
00:09:52,540 --> 00:09:56,080
So the question is - how do we get hold of a pandas data frame?
121

122
00:09:56,320 --> 00:10:05,350
Well we can come back up here where we're importing pandas and we can import the data frame from pandas.
122

123
00:10:05,410 --> 00:10:10,670
So from pandas import DataFrame.
123

124
00:10:10,840 --> 00:10:16,720
Now if you hit tab on your keyboard then Jupyter notebook should actually autocomplete some of the code
124

125
00:10:16,720 --> 00:10:17,490
for you.
125

126
00:10:17,650 --> 00:10:24,520
That way you won't make a typo here with say a lowercase f or something. Autocomplete is incredibly useful
126

127
00:10:24,610 --> 00:10:26,610
for avoiding these small mistakes.
127

128
00:10:26,620 --> 00:10:32,740
Now we can come back to our X and our y. Here, what we're gonna do is we're going to create a new data frame
128

129
00:10:33,160 --> 00:10:40,420
and this data frame is going to contain our production budgets so X is going to equal DataFrame open
129

130
00:10:40,420 --> 00:10:48,700
parentheses data comma columns is equal to square brackets and in the single quotes we're going to
130

131
00:10:48,700 --> 00:10:56,920
provide the column name. The column name for X is gonna be production_budget_usd so you can just copy
131

132
00:10:56,920 --> 00:11:02,230
this from the spreadsheet or you can type it out as long as you make sure that the spelling matches
132

133
00:11:02,350 --> 00:11:06,390
exactly and then your line of code should look like this.
133

134
00:11:06,400 --> 00:11:07,560
So, what are we doing here?
134

135
00:11:07,570 --> 00:11:14,110
We're creating a new data frame from our raw data which we've got here and we're selecting a single column
135

136
00:11:14,350 --> 00:11:21,580
from this data, namely the production budgets and that's how we're splitting up our data frame here for
136

137
00:11:21,580 --> 00:11:22,720
our X's.
137

138
00:11:22,750 --> 00:11:25,780
Now at this point I'd like to throw our challenge to you.
138

139
00:11:25,780 --> 00:11:30,570
I'd like you to pause the video and split up the data for our y's.
139

140
00:11:30,580 --> 00:11:36,760
Can you create a data frame just like this but instead of grabbing that first column can you grab the
140

141
00:11:36,850 --> 00:11:37,720
other column?
141

142
00:11:37,720 --> 00:11:42,040
The worldwide gross and then this information as our y.
142

143
00:11:42,500 --> 00:11:47,970
I'll give you a few seconds to pause the video and give this a go. Alright, 
143

144
00:11:48,170 --> 00:11:49,250
Here's the solution.
144

145
00:11:49,370 --> 00:11:57,200
You can actually copy the line above and paste it below and then just replace the column name with the
145

146
00:11:57,200 --> 00:12:00,390
column name for the worldwide gross revenue.
146

147
00:12:00,410 --> 00:12:06,740
So in this case you need to take this column name here and add it between the single quotes inside the
147

148
00:12:06,740 --> 00:12:08,030
square brackets.
148

149
00:12:08,030 --> 00:12:11,090
Having done this, we've separated our data.
149

150
00:12:11,090 --> 00:12:16,940
We've created two new data frames one called X which holds onto our features and one called
150

151
00:12:16,940 --> 00:12:20,030
y which holds onto our target.
151

152
00:12:20,060 --> 00:12:24,140
So let's execute the code in the cell and see what happens.
152

153
00:12:24,140 --> 00:12:29,140
So if we click Run here, then what you see is that we actually get an error.
153

154
00:12:29,330 --> 00:12:34,190
We get something that says: "name 'DataFrame' is not defined".
154

155
00:12:34,760 --> 00:12:39,230
And the reason we're getting this error is because our notebook actually doesn't know what a data frame
155

156
00:12:39,230 --> 00:12:40,030
is.
156

157
00:12:40,130 --> 00:12:41,040
But, why is that?
157

158
00:12:41,780 --> 00:12:48,320
If we go up here we can very, very clearly see that we're importing the DataFrame from pandas.
158

159
00:12:48,320 --> 00:12:53,780
The reason we're getting this error is because we've modified the cell, but we actually have not run
159

160
00:12:53,780 --> 00:12:55,010
this cell yet.
160

161
00:12:55,010 --> 00:13:01,550
In other words, we have to select this cell, run the cell and it's at this point that our notebook knows
161

162
00:13:01,550 --> 00:13:02,420
about the data frame.
162

163
00:13:03,140 --> 00:13:09,380
So if you come down here to where we're creating our X and our y and run the cell again this arrow will
163

164
00:13:09,380 --> 00:13:13,610
disappear, the code will now execute successfully.
164

165
00:13:13,610 --> 00:13:19,850
So now that we've successfully separated out our data let's visualize it and for that we need some functionality
165

166
00:13:19,850 --> 00:13:24,570
from another module. That module is called matplotlib.
166

167
00:13:24,620 --> 00:13:30,020
Matplotlib has a whole bunch of graphing and plotting functionality and this is the module that will
167

168
00:13:30,020 --> 00:13:32,090
help us create our charts.
168

169
00:13:32,270 --> 00:13:38,420
So let's import matplotlib into our notebook going to the very top where we've got all our import
169

170
00:13:38,420 --> 00:13:40,540
statements nicely organized.
170

171
00:13:40,750 --> 00:13:42,320
Let's add another one.
171

172
00:13:42,320 --> 00:13:45,720
Let's say import matplotlib.
172

173
00:13:45,740 --> 00:13:52,970
Now the specific plotting functionality that we actually need is only a small part of matplotlib
173

174
00:13:53,600 --> 00:13:57,300
and this plotting functionality is called pyplot.
174

175
00:13:57,410 --> 00:14:05,150
So if we import matplotlib.pyplot and hit Shift+Enter on our keyboard to execute the cell then
175

176
00:14:05,150 --> 00:14:10,610
we can start creating our charts. Coming down to the bottom of our notebook, in a new cell,
176

177
00:14:10,610 --> 00:14:17,240
we can now create our first chart. Let's create a scatter plot. So let's get a hold of 
177

178
00:14:17,750 --> 00:14:25,380
matplotlib.pyplot.scatter(X, y).
178

179
00:14:25,430 --> 00:14:31,130
What this line of code will do is it will create our scatter plot for us to show our chart in our notebook.
179

180
00:14:31,340 --> 00:14:38,060
We actually have to tell matplotlib to show our plot and we can do this with matplotlib.pyplot.show
180

181
00:14:38,060 --> 00:14:44,750
and then parentheses at the end. Let's hit Shift+Enter and see what this looks like. After
181

182
00:14:44,750 --> 00:14:47,480
our cell executes we should see something like this.
182

183
00:14:47,600 --> 00:14:49,370
Now I want to do a couple of things.
183

184
00:14:49,400 --> 00:14:52,370
First off, I want to simplify our code.
184

185
00:14:52,370 --> 00:14:58,100
And second I want to prettify our chart so that it becomes a lot more informative.
185

186
00:14:58,100 --> 00:15:00,620
The problem with the code is that it's a little bit long.
186

187
00:15:00,680 --> 00:15:06,470
If you go online and you take a look at some of the documentation you rarely see code written like this.
187

188
00:15:06,680 --> 00:15:10,100
What people do is they shorten this bit of the code.
188

189
00:15:10,100 --> 00:15:15,290
So what we can do is we can go to our import statements at the very top and we can create something
189

190
00:15:15,290 --> 00:15:24,950
called an alias for our pyplot and we can do this by simply writing as plt and this as keyword gives
190

191
00:15:25,400 --> 00:15:27,620
our pyplot this short name.
191

192
00:15:27,620 --> 00:15:34,550
So we're importing matplotlib.pyplot as plt and this means we can come down here and instead
192

193
00:15:34,550 --> 00:15:41,380
of writing all of this and then scatter we just write plt.scatter and here we just write plt.show
193

194
00:15:41,390 --> 00:15:44,130
and just to prove that this works.
194

195
00:15:44,240 --> 00:15:49,490
I'm going to have to execute this cell first because I've made some changes here and then I can come
195

196
00:15:49,490 --> 00:15:56,180
down here and execute this cell and what we should see is the same result as before.
196

197
00:15:56,180 --> 00:15:59,830
So what can we do to make this chart a lot more informative?
197

198
00:15:59,900 --> 00:16:06,620
Well we can add a title to it or we can add labels to the axes to make it a lot more clear what's going
198

199
00:16:06,620 --> 00:16:07,270
on.
199

200
00:16:07,460 --> 00:16:13,090
To do that we can adopt a very, very similar approach to what we did up here.
200

201
00:16:13,100 --> 00:16:15,390
We had a; we had some sort of object.
201

202
00:16:15,530 --> 00:16:21,050
Then we put a dot after it and then we told it to do something. Up here we we're using our data object,
202

203
00:16:21,400 --> 00:16:24,010
but with our chart we're going to use plt.
203

204
00:16:24,020 --> 00:16:30,590
So to add a title to our chart we simply write plt.title and then in the parentheses we provide
204

205
00:16:30,590 --> 00:16:31,330
the title.
205

206
00:16:31,400 --> 00:16:39,140
So I'm going to call this chart "Film Cost vs Global Revenue" and when I hit Shift+Enter to refresh
206

207
00:16:39,140 --> 00:16:42,510
the charts then the title will appear just above.
207

208
00:16:42,890 --> 00:16:52,020
And similarly, we can add labels to the axes. So with plt.xlabel we can add production budget in dollars
208

209
00:16:52,290 --> 00:16:58,740
to the x-axis and with plt.ylabel we can add worldwide gross to the y-axis.
209

210
00:16:58,740 --> 00:16:59,450
Brilliant.
210

211
00:16:59,460 --> 00:17:01,080
Now, what else can we do?
211

212
00:17:01,080 --> 00:17:03,390
Well first, let's make our chart larger.
212

213
00:17:03,900 --> 00:17:11,490
So if I come up here and I write plt.figure I can change the size of our chart and I can do that
213

214
00:17:11,490 --> 00:17:19,840
by setting the figures figure size with figsize as equal to and then parentheses and I can supply a
214

215
00:17:19,860 --> 00:17:20,970
width and a height here.
215

216
00:17:21,120 --> 00:17:23,040
So I'm gonna go with ten by six.
216

217
00:17:23,130 --> 00:17:27,820
And if I hit Shift+Enter then my chart will update and become much larger than before.
217

218
00:17:27,900 --> 00:17:33,960
And at this point what's becoming very clear is that our y-axis and our x-axis are actually going below
218

219
00:17:33,960 --> 00:17:34,630
zero.
219

220
00:17:34,680 --> 00:17:38,600
So there's some space here to plot anything that is a negative number.
220

221
00:17:38,790 --> 00:17:45,030
But if we look up here we can actually see that for both our production budgets and our revenue
221

222
00:17:45,150 --> 00:17:47,300
we don't go anywhere near zero.
222

223
00:17:47,340 --> 00:17:54,450
So what we can do for our chart is we can set a range for what should be displayed on the x-axis and
223

224
00:17:54,450 --> 00:17:57,010
the y-axis to customize our chart.
224

225
00:17:57,060 --> 00:18:01,270
In this way we would write plt.ylim,
225

226
00:18:01,440 --> 00:18:05,880
and then in the parentheses we set a minimum and a maximum value.
226

227
00:18:05,880 --> 00:18:13,590
So for our y, I think we can go between 0 and 3 billion just so that we capture this data point up here
227

228
00:18:13,680 --> 00:18:15,200
in the top right corner.
228

229
00:18:15,360 --> 00:18:21,810
So I'll add plt.ylim and then in the parentheses 0, 3 and then billion; billion
229

230
00:18:21,810 --> 00:18:23,880
has nine zeros I believe.
230

231
00:18:23,910 --> 00:18:27,390
So one two three...six seven eight nine.
231

232
00:18:27,510 --> 00:18:30,960
Let's hit Shift+Enter on the cell and refresh that chart.
232

233
00:18:31,120 --> 00:18:32,540
And let's take a look at our changes.
233

234
00:18:33,030 --> 00:18:35,650
Now that empty space below has disappeared.
234

235
00:18:35,730 --> 00:18:38,020
So let's do the same thing for the x-axis.
235

236
00:18:38,190 --> 00:18:44,130
And actually I want to leave that over to you as a challenge. See if you can figure out how to add some
236

237
00:18:44,130 --> 00:18:52,860
code to the cell to set the limit on the x-axis to have a minimum value of zero but a maximum value
237

238
00:18:53,130 --> 00:18:55,640
of 450 million.
238

239
00:18:55,800 --> 00:19:01,650
That way when you refresh you should get rid of this whitespace here and we should see our chart much
239

240
00:19:01,650 --> 00:19:02,610
more clearly.
240

241
00:19:02,610 --> 00:19:08,460
I'll give you a few seconds to pause the video before I show you the solution ready.
241

242
00:19:08,470 --> 00:19:09,280
Here we go.
242

243
00:19:09,280 --> 00:19:13,240
It's very similar to what we did with our y-axis.
243

244
00:19:13,480 --> 00:19:18,380
In this case we have to modify one thing in our code -  instead of ylim,
244

245
00:19:18,410 --> 00:19:27,820
we're gonna go for xlim and instead of three billion we're gonna go for 450 million which is 450 followed
245

246
00:19:27,820 --> 00:19:29,870
by six zeros.
246

247
00:19:29,890 --> 00:19:35,580
If I hit Shift+Enter on my cell then I should see my chart update like so.
247

248
00:19:35,600 --> 00:19:39,220
But we can actually improve the styling a little bit further.
248

249
00:19:39,220 --> 00:19:45,220
One thing we can do for example is we can add transparency to our dots here, so we can go to our scatter
249

250
00:19:45,220 --> 00:19:51,580
plot and similar to what we did here with setting the figure size for the figure,
250

251
00:19:51,970 --> 00:19:58,990
so the overall size of the chart, we can actually set the transparency for the dots in the scatter plot
251

252
00:19:59,770 --> 00:20:05,480
and we can do that by putting a comma after the y and setting something called the alpha value.
252

253
00:20:05,920 --> 00:20:13,150
So by setting alpha equal to 0.3 and hitting Shift+Enter then we'll see that our dots have
253

254
00:20:13,150 --> 00:20:18,880
become a lot more transparent and this will give us a good appreciation for the number of data points
254

255
00:20:19,030 --> 00:20:21,370
that we have in certain areas of the chart.
255

256
00:20:21,400 --> 00:20:27,100
So down here we have loads and loads of movies and loads of data points and as we go to the top right
256

257
00:20:27,550 --> 00:20:29,480
there's fewer and fewer films.
257

258
00:20:29,620 --> 00:20:31,840
So where are we at now at this point?
258

259
00:20:31,840 --> 00:20:37,810
We've done some excellent work visualizing our data and this has helped us spot some of the clear outliers
259

260
00:20:37,960 --> 00:20:39,450
in the film world.
260

261
00:20:39,550 --> 00:20:46,210
For example this film right here has had an enormous production cost and also made a lot of money.
261

262
00:20:46,270 --> 00:20:48,430
This movie is called Avatar by the way.
262

263
00:20:48,430 --> 00:20:53,980
If you're wondering and looking at this chart you can see just how out of the ordinary this film was
263

264
00:20:54,040 --> 00:20:55,550
relative to other movies.
264

265
00:20:55,660 --> 00:21:00,770
But there are also some films that have made very very little money but cost a fortune.
265

266
00:21:01,030 --> 00:21:03,430
And these films are down here.
266

267
00:21:03,460 --> 00:21:09,850
That said, what's very clear from this chart is that most films are actually smaller productions less
267

268
00:21:09,850 --> 00:21:11,490
than say 1 million.
268

269
00:21:11,710 --> 00:21:17,080
And we can see that from this very dense cloud of data points in the lower left hand corner.
269

270
00:21:17,200 --> 00:21:23,650
Looking at this chart we can also start to understand more about the relationship or the potential relationship
270

271
00:21:23,680 --> 00:21:31,060
between movie budgets and movie revenue because there indeed seems to be some sort of upward trend that's
271

272
00:21:31,270 --> 00:21:36,310
visible in the chart and higher budget films do indeed appear to have higher revenue.
272

273
00:21:36,430 --> 00:21:43,060
But how much higher exactly? But how much higher exactly and how strong is the relationship?
273

274
00:21:43,120 --> 00:21:49,210
To answer these questions we will need to turn to our linear regression. Our linear regression can help
274

275
00:21:49,210 --> 00:21:51,580
us quantify this relationship.
275

276
00:21:51,580 --> 00:21:55,330
But before we do that in the next lesson let's save our work.
276

277
00:21:55,360 --> 00:21:59,110
We've written quite a lot of code and it would be a shame to lose it.
277

278
00:21:59,290 --> 00:22:05,200
And I can tell you one thing trying Jupyter online is prone to get you disconnected if you leave it
278

279
00:22:05,200 --> 00:22:06,670
alone for too long.
279

280
00:22:06,730 --> 00:22:12,480
So go to File and then go to Download as > Jupyter notebook.
280

281
00:22:12,550 --> 00:22:20,170
And this is the .ipynb extension. That way, if you do get disconnected, your work is saved and
281

282
00:22:20,170 --> 00:22:26,200
you can come back here to upload your Jupyter notebook if need to continue where you left off.
282

283
00:22:26,290 --> 00:22:27,490
I'll see you in the next lesson.
